// 请求三级分类列表的函数

import Ajax from './ajax'
import mockAjax from './mockAjax'


//get
// 获取三级列表数据
export const reqCategroyList = ()=>{
    return Ajax({
        url:'/product/getBaseCategoryList',
        method:'get'
    })
}
export const reqBannerList = () =>{
    return mockAjax({
        url:'/banner',
        method:'get'
    })
}
export const reqFloorList = () => {
    return mockAjax({
        url:'/floor',
        method:'get'
    })
}
// 获取商品详情页数据
export const reqGoodsDetailInfo = (skuId) => {
    return Ajax({
        url:`/item/${ skuId }`,
        method:'get'
    })
}
// 获取购物车列表
export const reqShopCartList = () => {
    return Ajax({
        url:'/cart/cartList',
        method:'get'
    })
}
// 切换商品选中状态
// /api/cart/checkCart/{skuID}/{isChecked}
export const reqUpdateOneIsChecked = (skuId,isChecked) => {
    return Ajax({
        url:`/cart/checkCart/${skuId}/${isChecked}`,
        method:'get'
    })
}
// 获取验证码
// /api/user/passport/code
export const reqGetCode = (phone) => {
    return Ajax({
        url:`/user/passport/sendCode/${phone}`,
        method:'get'
    })
}
// 获取用户信息
// /user/passport/auth/getUserInfo
export const reqUserInfo = () => {
    return Ajax({
        url:'/user/passport/auth/getUserInfo',
        method:'get'
    })
}
// 请求退出登录
// /api/user/passport/logout
export const reqLogout = () => {
    return Ajax({
        url:'/user/passport/logout',
        method:'get'
    })
}

// 获取订单交易页信息
// /api/order/auth/trade
export const reqTradeInfo = () => {
    return Ajax({
        url:'/order/auth/trade',
        method:'get'
    })
}

// 获取用户地址信息
// /api/user/userAddress/auth/findUserAddressList
export const reqAddressList = () => {
    return Ajax({
        url:'/user/userAddress/auth/findUserAddressList',
        method:'get'
    })
}

// 提交订单
// /api/order/auth/submitOrder?tradeNo={tradeNo}
export const reqSubmitOrder = (tradeNo,tradeInfo) => {
    return Ajax({
        url:`/order/auth/submitOrder?tradeNo=${tradeNo}`,
        method:'post',
        data:tradeInfo
    })
}

// 获取订单支付信息
// /api/payment/weixin/createNative/{orderId}
export const reqPayInfo = (orderId) => {
    return Ajax({
        url:`/payment/weixin/createNative/${orderId}`,
        method:'get'
    })
} 

// 查询订单支付判断
// /api/payment/weixin/queryPayStatus/{orderId}
export const reqPayStatus = (orderId) => {
    return Ajax({
        url:`/payment/weixin/queryPayStatus/${orderId}`,
        method:'get'
    })
}

// 获取我的订单信息
// /api/order/auth/{page}/{limit}
export const reqMyOrderInfo = (page,limit) => {
    return Ajax({
        url:`/order/auth/${page}/${limit}`,
        method:'get'
    })
}





//post
// 获取搜索页数据
export const reqGoodsList = (searchParams) => {
    return Ajax({
        url:'/list',
        method:'post',
        data:searchParams
    })
}
// 添加到购物车
// /api/cart/addToCart/{ skuId }/{ skuNum }
export const reqAddOrUpdateShopCart = (skuId,skuNum) => {
    return Ajax({
        url:`/cart/addToCart/${ skuId }/${ skuNum }`,
        method:'post'
    })
}
// 批量更改购物车选中状态
// /api/cart/batchCheckCart/{isChecked}
export const reqUpdateAllIsChecked = (isChecked,skuIds) => {
    return Ajax({
        url:`/cart/batchCheckCart/${isChecked}`,
        method:'post',
        data:skuIds
    })
}

// 注册
// /api/user/passport/register
export const reqRegisterInfo = (userInfo) => {
    return Ajax({
        url:'/user/passport/register',
        method:'post',
        data:userInfo
    })
}

// 登录页面
// /api/user/passport/login
export const reqLogin = (userInfo) => {
    return Ajax({
        url:'/user/passport/login',
        method:'post',
        data:userInfo
    })
}





// delete
// 删除单个购物车
// /api/cart/deleteCart/{skuId}
export const reqDeleteShopCart = (skuId) => {
    return Ajax({
        url:`/cart/deleteCart/${skuId}`,
        method:'delete'
    })
}
// 批量删除选中状态的购物车
// /api/cart/batchDeleteCart
export const reqDeleteAllShopCart = (skuIds) => {
    return Ajax({
        url:'/cart/batchDeleteCart',
        method:'delete',
        data:skuIds
    })
}


// 测试接口函数
// reqCategroyList()
// console.log(reqBannerList());
// console.log(reqFloorList());
// reqGoodsList({})
// reqGoodsDetailInfo(505)
// reqAddOrUpdateShopCart(12,5)
// reqShopCartList()
// reqUserInfo()



